<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
       select{
           width: 100px;
       }

    </style>
</head>
<body>

      <span>请选你购买的数量:</span>
      <select name="" id="num">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
      </select>
      <span>每个单价为<span id='price'>10</span>元</span>
      <span>总计：<span id='tolPrice'>10</span>元</span>
    
</body>
</html>

<script>

  let selectObj = document.getElementById('num');

  //console.log(selectObj.value);

  selectObj.onchange=()=>{
      //获得选中的值
      let val=parseInt(selectObj.value);
      //console.log(val);
      //获得单价
      let price =parseInt(document.getElementById('price').innerHTML);
       //把结果写到总计中
       document.getElementById('tolPrice').innerHTML=(val*price);


  }

</script>